package com.kcn.xml;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ExcelReader {
	private List<Invoice> invoices=new ArrayList<Invoice>();
	
	public List<Invoice> read() throws BiffException,IOException {
		try {
			File fl = new File("d:/aaaa.xls");
			System.out.println(fl.getName());
			Workbook wb = Workbook.getWorkbook(fl);
			Sheet st = wb.getSheet(0);
			for(int i=0;i<st.getRows();i++){
				Invoice iv=new Invoice();
				iv.setFpdm(st.getCell(0,i).getContents());
				iv.setFpmc(st.getCell(1,i).getContents());
				iv.setFphm(st.getCell(2,i).getContents());
				iv.setKprq(st.getCell(3,i).getContents());
				iv.setFkfmc(st.getCell(4,i).getContents());
				iv.setJehj(st.getCell(5,i).getContents());
				iv.setKplx(st.getCell(6,i).getContents());
				iv.setYfpdm(st.getCell(7,i).getContents());
				iv.setYfphm(st.getCell(8,i).getContents());
				iv.setPm(st.getCell(9,i).getContents());
				iv.setDw(st.getCell(10,i).getContents());
				iv.setDj(st.getCell(11,i).getContents());
				iv.setSl(st.getCell(12,i).getContents());
				iv.setJe(st.getCell(13,i).getContents());
				invoices.add(iv);				
			}
			wb.close();
		} catch (BiffException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return invoices;
	}
}
